#ifndef USER_H
#define USER_H
#include <string>
#include <utility>
#define ADMIN "Ushio"
#define ADMIN_PSW "qwerty"
#include "Cart.h"
#include <iostream>
class Server;
class Interface;
class User {
  friend class Server;
  friend class Interface;

public:
  User(std::string name = "", std::pair<unsigned long long , unsigned long long> keys ={}, double money = 1)
      : name(name), keys(keys), user_cart(), money(money) {}
  virtual void add_good(const good &g, cart *a = nullptr);
  virtual int del_good(const good &g,int num, cart *a = nullptr);
  virtual int del_good(int index, cart *a = nullptr);
  friend std::ostream &operator<<(std::ostream &os, const User &cl);
  void from_file(std::ifstream &fs);
  void to_file(std::ofstream &fs);

private:
  std::string name;
  std::pair<unsigned long long, unsigned long long> keys;
  double money;
  cart user_cart;
};
class Admin : User {
public:
  static Admin *admin_login(std::string name, std::string psw);
  ~Admin() { count--; }

private:
  static unsigned count;
  Admin(const std::string &name, const std::string &psw) : User() {
    count++;
  }
  int login(const std::string &name, const std::string &psw);
  void add_good(const good &g, cart *a = nullptr) override;
  int del_good(const good &g,int num, cart *a = nullptr) override;
  Admin(const Admin &ad) = delete;
  Admin &operator=(const Admin &Admin) = delete;
};
#endif